This code just looks really wrong -- it seems to be stuffing things into OutputPage::getCategories() which seems clearly designed to only return a set of categories that have been previously set by something else; rather than a lazy loader it also seems to fetch them every time. Nor does it even check if the article exists before loading from the DB -- and in general it looks like it doesn't really fit in with other code. It also only lists itself as altering wgCategories, but it's changing what's in the OutputPage itself so this may affect other things.
* @return Array of strings
*/
public function getCategories() {
- // mCategories will only be filled if we're coming from the parser
- if ($this->getRequest()->getVal('action') != 'view') {
- $categories = array();
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select(
- 'categorylinks',
- array( 'cl_to' ),
- 'cl_from='. $this->getTitle()->getArticleId(),
- __METHOD__
- );
- foreach( $res as $row ) {
- $categories[] = $row->cl_to;
- }
- $this->mCategories = $categories;
- }
return $this->mCategories;
}